#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int maxCoins(vector<int>& piles) {
    sort(piles.begin(), piles.end());
    int l = 0, n = piles.size();
    int res = 0;
    for (int i = n - 2; i > l; i -= 2, l++)
        res += piles[i];
    return res;
}

// s Ϊǰ׺
// s >= tot - s
// 2s >= tot
// s >= tot / 2 = (tot + 1) / 2
int waysToSplitArray(vector<int>& nums) {
    int n = nums.size();
    vector<long long> a(n + 1);

    for (int i = 1; i <= n; i++)
        a[i] = a[i - 1] + nums[i - 1];

    int res = 0;
    for (int i = 1; i < n; i++)
        if (a[i] >= a[n] - a[i])
            res++;
    return res;
}